local xiaoji = fk.CreateSkill {
  name = "cpt11__xiaoji",
}

Fk:loadTranslationTable{
    ["cpt11__xiaoji"] = "枭姬",
    [":cpt11__xiaoji"] = "当你失去装备区的一张牌后，你可以选择一项：1.摸两张牌；2.回复1点体力。",

    ["cpt11__xiaoji_drawcards"] = "摸两张牌",
    ["cpt11__xiaoji_recover"] = "回复1点体力",

    ["$cpt11__xiaoji1"] = "哼！",
    ["$cpt11__xiaoji2"] = "看我的厉害！",
}

xiaoji:addEffect(fk.AfterCardsMove, {
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(xiaoji.name) then return end
    for _, move in ipairs(data) do
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            return true
          end
        end
      end
    end
  end,
  trigger_times = function(self, event, target, player, data)
    local i = 0
    for _, move in ipairs(data) do
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            i = i + 1
          end
        end
      end
    end
    return i
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askToSkillInvoke(player, { skill_name = xiaoji.name }) then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local choices = {"cpt11__xiaoji_drawcards"}
    if player:isWounded() then
        table.insert(choices, "cpt11__xiaoji_recover")
    end
    local choice = player.room:askToChoice(player,{
        skill_name = xiaoji.name,
        choices = choices,
        cancelable = false,
    })
    if choice == "cpt11__xiaoji_drawcards" then
    player:drawCards(2, xiaoji.name)
    else
        player.room:recover{
            who = player,
            num = 1,
            skillName = xiaoji.name
        }
    end
  end,
})

xiaoji:addAI({
  think_skill_invoke = function(self, ai, skill_name, prompt)
    return ai:getBenefitOfEvents(function(logic)
      logic:drawCards(ai.player, 2, self.skill.name)
    end) > 0
  end,
})

return xiaoji